<h1>How To Use</h1>
<p>This section covers the VisualWorks version of Kai.</p>

<h2>Learning Kai by example</h2>

<p>Currently, Kai does not have a graphical user interface to run it. You therefore need to run it by hand. Here is an example:</p>
<pre>	| kai |
	kai := KaiProfiler new.
	kai iterations: 500.
	kai 
		profile:  [
			| view ui | 
			view := MondrianViewRenderer new.
			view nodes: Collection withAllSubclasses.
			view edgesFrom: #superclass.
			view treeLayout.
			ui := Mondrian.MondrianUI new.
			view installOn: ui drawing ]
		inClassCategoriesMatching: 'Roassal*'
		inNamespace: Roassal.
	kai visualize.</pre>
	
<p>You first need to instantiate the class KaiProfiler. The number of iterations correspond to the amount of times the code to be profiled is executed. It typically ranges from 1 to 2000. This is useful when the code has a short execution time, because it may incorrectly estimate the amount of time spent in each method. </p>
<p>To understand Kai's blueprint, please visit the <a title="Kai Blueprint" class="op-a" href="#">Kai Blueprint</a> section.</p>

<h2>Accessing:</h2>

<p>Kai profiler is accessible by executing the following lines:</p>
<pre>KaiProfiler new iterations: X;
	profile:[aBlock];
	visualize.</pre>
<p>This <code>aBlock</code> is the expression to analyze, and the number of iterations X is the number of times the profiler will execute this expression. This number influences the amount of information the profiler can collect. For some expressions, especially those with a short execution time, a higher number of executions is required. Kai offers a legend with an evaluation of the number of iterations, indicating if a higher number is necessary for a better profiling result.</p>
<p>The last line is for the visualization on Mondrian to be displayed.</p>

<h2>Navigation:</h2>

<p>Kai will soon be integrated with the programming environment.</p>

<h2>Interaction with the visualization:</h2>

<p>By right clicking on a method, a set of options are available:</p>
<ul>
	<li>View incoming invocations: Using the same Kai Blueprint a new visualization will be open showing all the incoming calls from this method. The targeted method is shown with a cyan border.</li>
	<li>View outgoing invocations: Same as before, but with the outgoing methods from the execution call graph.</li>
	<li>Invocations state changes: A complete new visualization will be displayed, showing an heuristic with the method that produces state changes of objects.</li>
	<li>Browse the method on the framework system browser.</li>
</ul>
<p>On VisualWorks, Kai also includes the option of inspecting the TimeProfiler report, which can be the complete one or starting from the selected method.</p>
